package pub.dsb.example.rx.core;

import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.CompletableObserver;
import io.reactivex.rxjava3.disposables.Disposable;

/**
 * <p>
 *
 * </p>
 *
 * @author Yi
 * @version V1.0.0
 * @date 2020/12/24 14:46
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人} 2020/12/24 14:46
 * @modify reason: {方法名}:{原因}
 * ...
 * @since V1.0.0
 */
public class CompletableTest {

    /**
     * Completable
     *
     * @param args
     */
    public static void main(String[] args) {
        System.out.println("DEMO 1 -------------");
        Completable.create(sub -> {
            sub.onComplete(); //单一onComplete或者onError
        }).subscribe(new CompletableObserver() {
            @Override
            public void onSubscribe(@NonNull Disposable d) {
                System.out.println("onSubscribe!");
            }

            @Override
            public void onComplete() {
                System.out.println("completed!");
            }

            @Override
            public void onError(@NonNull Throwable e) {
                System.out.println(e.getMessage());
            }
        });
    }
}
